/* Created by Aquariuslt on 5/20/17.*/


UpFoodController.$inject = ['foodsService','$scope','$location','$stateParams'];
function UpFoodController(foodsService,$scope,$location,$stateParams) {
   var $ = require('jquery');
    $('#nav').show();
  var vm = $scope.vm = {
      show_error: true,
            show_type: 2,
            food: {ftype:2},
            types:[
                {value:1,label:'Drinks'},
                {value:2,label:'Staple food'},
                {value:3,label:'Snack'},
                {value:4,label:'Combo'}
                ]
        };
        vm.merchant = JSON.parse(sessionStorage.merchant);
        var temp = $scope.temp ={};
        temp.defaultLable = vm.types[vm.food.ftype-1].label;
        temp.defaultValue = vm.food.ftype;

    console.log($stateParams.foodid);
    foodsService.getFoodById($stateParams.foodid,function(err,data){
        vm.food = data;
        console.log(vm.food);
    });

        vm.submit = function () {
            console.log('submit')
             if(vm.food.ftype==''){
                $('#ftype').val(temp.defaultValue);
             }
            $('#basic_form').submit();
        };

        



}

module.exports = UpFoodController;